package com.bjtu.laorenyouhao.laoren.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bjtu.laorenyouhao.laoren.entity.LaorenJianhurenEntity;
import com.bjtu.laorenyouhao.laoren.service.LaorenJianhurenService;
import com.bjtu.common.utils.PageUtils;
import com.bjtu.common.utils.R;



/**
 * 老人监护人信息
 *
 * @author yangyalong
 * @email yangyalong@gmail.com
 * @date 2021-07-08 20:27:26
 */
@RestController
@RequestMapping("laoren/laorenjianhuren")
public class LaorenJianhurenController {
    @Autowired
    private LaorenJianhurenService laorenJianhurenService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = laorenJianhurenService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		LaorenJianhurenEntity laorenJianhuren = laorenJianhurenService.getById(id);

        return R.ok().put("laorenJianhuren", laorenJianhuren);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody LaorenJianhurenEntity laorenJianhuren){
		laorenJianhurenService.save(laorenJianhuren);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody LaorenJianhurenEntity laorenJianhuren){
		laorenJianhurenService.updateById(laorenJianhuren);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		laorenJianhurenService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
